package com.ruoyi.system.assembler;


import com.ruoyi.common.config.PayBaseInfo;
import com.ruoyi.common.vo.PayReq;
import com.ruoyi.system.domain.PaymentRecord;
import com.ruoyi.system.domain.vo.PaySubmitVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface PayAssembler {
    PayAssembler INSTANCE = Mappers.getMapper(PayAssembler.class);

    PaymentRecord convertPaySubmitVoToPaymentRecord(PaySubmitVo paySubmitVo);

    @Mapping(source = "paymentRecord.clientip", target = "clientip")
    @Mapping(source = "paymentRecord.device", target = "device")
    @Mapping(source = "paymentRecord.totalValue", target = "money")
    @Mapping(target = "name", expression = "java(com.github.houbb.pinyin.util.PinyinHelper.toPinyin(paymentRecord.getProductCnName(), com.github.houbb.pinyin.constant.enums.PinyinStyleEnum.NORMAL))")
    @Mapping(source = "payBaseInfo.notify_url", target = "notify_url")
    @Mapping(source = "paymentRecord.id", target = "out_trade_no")
    @Mapping(source = "payBaseInfo.pid", target = "pid")
    @Mapping(source = "payBaseInfo.return_url", target = "return_url")
    @Mapping(source = "paymentRecord.signType", target = "sign_type")
    @Mapping(source = "paymentRecord.type", target = "type")
    PayReq convertPaymentRecordToPayReq(PaymentRecord paymentRecord, PayBaseInfo payBaseInfo);
}
